Inside Macintosh: QuickTime Components

Previous | Chapter Top | Chapter Contents | Next

Managing Controller Attributes

Movie controller components provide a number of functions that allow your application to control the display attributes of a movie controller. For example, you can detach the controller from its movie, so that the controller and movie can be managed as separate graphics entities. In addition, movie controller components provide a number of functions that allow you to work with a controller's boundary rectangles and regions. For a complete discussion of these rectangles and regions, see "Spatial Properties," which begins on Spatial Properties .

The MCSetControllerAttached function lets you control whether the movie controller is attached to its movie. The MCIsControllerAttached function allows you to determine if a controller is attached to its movie.

You can use the MCSetControllerPort and MCGetControllerPort functions to work a movie controller's graphics port.

The MCSetVisible and MCGetVisible functions enable you to control the visibility of the movie controller.

The MCSetControllerBoundsRect and MCGetControllerBoundsRect functions help you work with a movie controller's boundary rectangle. You can use the MCGetControllerBoundsRgn and MCGetControllerWindowRgn functions if the controller is not rectangular. You can position a controller and its movie separately by calling the MCPositionController function.

MCPositionController

The MCPositionController function allows you to control the position of a movie and its controller on the computer display.

pascal ComponentResult MCPositionController (MovieController mc,
                                         const Rect *movieRect,
                                         const Rect *controllerRect,
                                         long someFlags);
mc
Specifies the movie controller for the operation. You obtain this identifier from the Component Manager's OpenComponent or OpenDefaultComponent function, or from the NewMovieController function (described on NewMovieController ).
movieRect
Points to a Rect structure that specifies the coordinates of the movie's boundary rectangle. (For details on the Rect structure, see the chapter "Basic QuickDraw" in Inside Macintosh: Imaging .)
controllerRect
Points to a Rect structure that specifies the coordinates of the controller's boundary rectangle. The movie controller component always centers the control portion of the controller inside this rectangle. The movie controller component only uses this parameter when the control portion of the controller is detached from the movie. If you are working with an attached controller, you can set this parameter to nil .
someFlags
If you set these flags to 0, the movie controller component centers the movie in the rectangle specified by movieRect and scales the movie to fit in that rectangle. You may control how the movie is drawn by setting one or more of the following flags to 1:
mcTopLeftMovie
If this flag is set to 1, the movie controller component places the movie into the upper-left corner of the display rectangle specified by the movieRect parameter. The component scales the movie to fit into the rectangle. Note that the control portion of the controller may fall outside of the rectangle, depending upon the results of the scaling operation.
mcScaleMovieToFit
If this flag is set to 1, the movie controller component resizes the movie to fit into the display rectangle specified by the movieRect parameter after it places the control portion of the controller into the rectangle.
If you set this flag and the mcTopLeftMovie flag to 1, the movie controller component resizes the movie to fit into the specified rectangle and places the control portion of the controller outside of the rectangle.
mcPositionDontInvalidate
If this flag is set to 1, the movie controller component is requested not to invalidate areas of the window that are changed as a result of repositioning the movie or the controller. This flag is useful for applications that use the movie controller as part of a larger document. In particular, if the document is scrolled using QuickDraw's ScrollRect routine, optimal redrawing occurs (that is, scrolled areas are not redrawn) if this flag is set. For details on ScrollRect , see the chapter "Basic QuickDraw" in Inside Macintosh: Imaging .

DESCRIPTION

The MCPositionController function works with controllers that are attached to movies and controllers that are not attached to movies.

MCSetControllerAttached

The MCSetControllerAttached function allows your application to control whether a movie controller is attached to its movie or detached from it. "About Movie Controller Components," which begins on About Movie Controller Components , discusses the differences between attached and detached movie controllers.

pascal ComponentResult MCSetControllerAttached
                                         (MovieController mc,
                                          Boolean attach);
mc
Specifies the movie controller for the operation. You obtain this identifier from the Component Manager's OpenComponent or OpenDefaultComponent function, or from the NewMovieController function (described on NewMovieController ).
attach
Specifies the action for this function. Set the attach parameter to true to cause the controller to be attached to its movie. Set this parameter to false to detach the controller from its movie.

DESCRIPTION

By default, a new movie controller is attached to its movie.

SPECIAL CONSIDERATIONS

Your application should not make any assumptions about the location of an attached movie controller with respect to its movie. The controller may be above, below, or surrounding the movie image.

SEE ALSO

If you need to know the location of the controller, you can use the MCGetControllerBoundsRect function, described on MCGetControllerBoundsRect , to obtain its boundary rectangle.

MCIsControllerAttached

The MCIsControllerAttached function returns a value that indicates whether a movie controller is attached to its movie.

pascal ComponentResult MCIsControllerAttached
                                         (MovieController mc);
mc
Specifies the movie controller for the operation. You obtain this identifier from the Component Manager's OpenComponent or OpenDefaultComponent function, or from the NewMovieController function (described on NewMovieController ).

DESCRIPTION

The MCIsControllerAttached function returns a ComponentResult value that indicates whether a movie controller is attached to its movie. If the controller is attached, the returned value is set to 1. If the controller is not attached, the returned value is set to 0.

SEE ALSO

You can use the MCSetControllerAttached function, described in the previous section, to attach or detach a movie controller.

MCSetVisible

The MCSetVisible function allows your application to control the visibility of a movie controller.

pascal ComponentResult MCSetVisible (MovieController mc,
                                          Boolean visible);
mc
Specifies the movie controller for the operation. You obtain this identifier from the Component Manager's OpenComponent or OpenDefaultComponent function, or from the NewMovieController function (described on NewMovieController ).
visible
Specifies the action for this function. Set the visible parameter to true to cause the controller to be visible. Set this parameter to false to make the controller invisible.

DESCRIPTION

Movie controller components support badges, which allow you to create a visual cue that helps the user distinguish between static images and images that represent movies. The movie controller component displays a badge in the movie image whenever the movie is visible but the control portion of the controller is not visible. To work with movie controller badges, you must use the mcActionSetUseBadge action, which is described in "Movie Controller Actions," .

SPECIAL CONSIDERATIONS

By default, a new controller is hidden so that your application can freely set the display attributes before showing the controller to the user. You should note, however, that the MCNewAttachedController function (described on MCNewAttachedController ) automatically sets the movie controller to be visible. Your application must make the controller visible before the user can work with its associated movie.

SEE ALSO

You can use the MCGetVisible function, described in the next section, to determine the visibility of a movie controller.

MCGetVisible

The MCGetVisible function returns a value that indicates whether a movie controller is visible.

pascal ComponentResult MCGetVisible (MovieController mc);
mc
Specifies the movie controller for the operation. You obtain this identifier from the Component Manager's OpenComponent or OpenDefaultComponent function, or from the NewMovieController function (described on NewMovieController ).

DESCRIPTION

The MCGetVisible function returns a ComponentResult value that indicates whether a movie controller is visible. If the controller is visible, the returned value is set to 1. If the controller is not showing, the returned value is set to 0.

SEE ALSO

Use the MCSetVisible function, described in the previous section, to change the visibility of a movie controller.

MCDrawBadge

The MCDrawBadge function allows you to display a controller's badge. This function places the badge in an appropriate location based on the location of the controller's movie.

pascal ComponentResult MCDrawBadge (MovieController mc,
                                         RgnHandle movieRgn,
                                         RgnHandle *badgeRgn);
mc
Specifies the movie controller for the operation. You obtain this identifier from the Component Manager's OpenComponent or OpenDefaultComponent function, or from the NewMovieController function (described on NewMovieController ).
movieRgn
Specifies the boundary region of the controller's movie.
badgeRgn
Points to a region that is to receive information about the location of the badge--your application must dispose of this handle. The movie controller returns the region where the badge is displayed. If you are not interested in this information, you may set this parameter to nil .

DESCRIPTION

The MCDrawBadge function can be useful in circumstances where you are using a movie controller component but do not want to incur the overhead of having the QuickTime movie in memory all the time. This function allows you to display the badge without having to display the movie. In addition, you can use the badge region to perform mouse-down event testing.

MCSetControllerBoundsRect

The MCSetControllerBoundsRect function lets you change the position and size of a movie controller. A controller's boundary rectangle encloses the control portion of the controller. In addition, in cases where the movie is attached to the controller, the boundary rectangle also encloses the movie. Note that changing the size of the boundary rectangle may result in the movie being resized as well, if the movie is attached to the controller.

pascal ComponentResult MCSetControllerBoundsRect
                                          (MovieController mc,
                                         const Rect *bounds);
mc
Specifies the movie controller for the operation. You obtain this identifier from the Component Manager's OpenComponent or OpenDefaultComponent function, or from the NewMovieController function (described on NewMovieController ).
bounds
Points to a rectangle structure that contains the new boundary rectangle for the movie controller.

DESCRIPTION

Movie controller components can reject your request for a number of reasons. For example, some movie controller components may support only fixed-size controllers or controllers whose size is fixed in one dimension. Also, note that your application cannot change the location of an attached controller.

The movie controller component returns a value of controllerBoundsNotExact if the boundary rectangle has been changed but does not correspond to the rectangle you specified. In this case, the new boundary rectangle is always smaller than the requested rectangle.

RESULT CODES

controllerBoundsNotExact

-9996

Controller has altered the bounds you supplied

controllerHasFixedHeight

-9998

You cannot change the height of this controller

cannotMoveAttachedController

-9999

You cannot move an attached controller

SEE ALSO

To find the dimensions of the new boundary rectangle, call the MCGetControllerBoundsRect function, described in the next section.

MCGetControllerBoundsRect

The MCGetControllerBoundsRect function returns a movie controller's boundary rectangle. This rectangle reflects the size and location of the controller even if the controller is currently hidden. If the controller is detached from its movie, the rectangle encompasses only the controller, not the movie. If the controller is attached to its movie, the rectangle encompasses both the controller and the movie.

pascal ComponentResult MCGetControllerBoundsRect
                                          (MovieController mc,
                                          Rect *bounds);
mc
Specifies the movie controller for the operation. You obtain this identifier from the Component Manager's OpenComponent or OpenDefaultComponent function, or from the NewMovieController function (described on NewMovieController ).
bounds
Contains a pointer to a rect structure that is to receive the coordinates of the movie controller's boundary rectangle. If there is insufficient screen space to display the controller, the function may return an empty rectangle.

DESCRIPTION

The returned rectangle is the boundary rectangle for the region occupied by the controller and its movie (if the movie is attached to the controller), even if the controller is not rectangular.

SPECIAL CONSIDERATIONS

Note that if the controller cannot obtain enough screen space, the movie controller component may return an empty rectangle.

SEE ALSO

You can use the MCGetControllerBoundsRgn function, described in the next section, to obtain the boundary region for a controller. You can use the MCGetWindowRgn function, described on MCGetWindowRgn , to determine the portion of the window that is currently in use by the controller.

MCGetControllerBoundsRgn

Some movie controllers may not be rectangular in shape. The MCGetControllerBoundsRgn function returns the actual region occupied by the controller and its movie, if the movie is attached to the controller. If the movie is not attached to its controller, the boundary region encloses only the control portion of the controller. The rectangle returned by the MCGetControllerBoundsRect function (described in the previous section) bounds the region returned by MCGetControllerBoundsRgn .

pascal RgnHandle MCGetControllerBoundsRgn (MovieController mc);
mc
Specifies the movie controller for the operation. You obtain this identifier from the Component Manager's OpenComponent or OpenDefaultComponent function, or from the NewMovieController function.

DESCRIPTION

As with the MCGetControllerBoundsRect function, the MCGetControllerBoundsRgn function returns a region that reflects the size, shape, and location of the controller, even if the controller is hidden. Your application must dispose of the returned region.

The MCGetControllerBoundsRgn function returns a handle to the boundary region. Your application must dispose of this region.

RESULT CODES

Memory Manager errors

SEE ALSO

You can use the MCGetWindowRgn function, described in the next section, to determine the portion of the window that is currently in use by the controller.

MCGetWindowRgn

The MCGetWindowRgn function allows your application to determine the window region that is actually in use by a controller and its movie. The region returned by this function contains only the visible portions of the controller and its movie.

pascal RgnHandle MCGetWindowRgn (MovieController mc, WindowPtr w);
mc
Specifies the movie controller for the operation. You obtain this identifier from the Component Manager's OpenComponent or OpenDefaultComponent function, or from the NewMovieController function (described on NewMovieController ).
w
Identifies the window in which the movie controller and its movie are displayed, if the control portion of the controller is attached to the movie. If the controller is detached and in a separate window from the movie, specify one of the windows.

DESCRIPTION

The returned region may consist of several discontiguous areas. For example, if a controller is detached from its movie, the window region may define separate areas for the movie and the controller. If you want to consider just the controller, you must subtract the movie from the returned region.

Your application must dispose of the returned region.

The MCGetWindowRgn function returns a handle to the window region. Your application must dispose of this region.

RESULT CODES

Memory Manager errors

SEE ALSO

You can control the clipping region that is applied to the controller by calling the MCSetClip function, which is described in the next section.

MCSetClip

The MCSetClip function allows you to set a movie controller's clipping region. This clipping region is equivalent to the movie display clipping region supported by the Movie Toolbox.

pascal ComponentResult MCSetClip (MovieController mc,
                                          RgnHandle theClip,
                                          RgnHandle movieClip);
mc
Specifies the movie controller for the operation. You obtain this identifier from the Component Manager's OpenComponent or OpenDefaultComponent function, or from the NewMovieController function (described on NewMovieController ).
theClip
Contains a handle to a region that defines the controller's clipping region. This clipping region affects the entire movie controller and its movie, including the controller's badge and associated controls. Set this parameter to nil to clear the controller's clipping region.
movieClip
Contains a handle to a region that defines the clipping region of the controller's movie. This clipping region affects only the movie and the badge, not the movie controller. Set this parameter to nil to clear the movie clipping region.

DESCRIPTION

Your application must dispose of the regions you supply to the MCSetClip function.

SPECIAL CONSIDERATIONS

Do not use the Movie Toolbox's SetMovieDisplayClipRgn function to modify movies that are associated with movie controllers.

RESULT CODES

Memory Manager errors

SEE ALSO

You can retrieve information about a controller's clipping information by calling the MCGetClip function, which is described in the next section.

MCGetClip

The MCGetClip function allows you to obtain information describing a movie controller's clipping regions.

pascal ComponentResult MCGetClip (MovieController mc,
                                          RgnHandle *theClip,
                                          RgnHandle *movieClip);
mc
Specifies the movie controller for the operation. You obtain this identifier from the Component Manager's OpenComponent or OpenDefaultComponent function, or from the NewMovieController function (described on NewMovieController ).
theClip
Contains a pointer to a field that is to receive a handle to the clipping region of the entire movie controller. You must dispose of this region when you are done with it. If you are not interested in this information, you may set this parameter to nil .
movieClip
Contains a pointer to a field that is to receive a handle to the clipping region of the controller's movie. You must dispose of this region when you are done with it. If you are not interested in this information, you may set this parameter to nil .

RESULT CODES

Memory Manager errors

SEE ALSO

You can set a controller's clipping information by calling the MCSetClip function, which is described in the previous section.

MCSetControllerPort

The MCSetControllerPort function allows your application to set the graphics port for a movie controller. You can use this function to place a movie and its associated movie controller in different graphics ports. If you are using an attached controller, both the controller and the movie's graphics ports are changed. If you are using a detached controller, this function changes only the graphics port of the control portion of the controller. You must use the Movie Toolbox's SetMovieGWorld function followed by the MCMovieChanged function to change other portions.

pascal ComponentResult MCSetControllerPort (MovieController mc,
                                          CGrafPtr gp);
mc
Specifies the movie controller for the operation. You obtain this identifier from the Component Manager's OpenComponent or OpenDefaultComponent function, or from the NewMovieController function (described on NewMovieController ).
gp
Points to the new graphics port for the movie controller. Set this parameter to nil to use the current graphics port.

DESCRIPTION

The movie controller component may use the foreground and background colors from the graphics port at the time the MCSetController function is called to colorize the movie controller.

Movie controller components use the MCSetControllerPort function each time you create a new movie controller. Hence, your component must be set to a valid port before creating a new movie controller.

MCGetControllerPort

The MCGetControllerPort function returns a movie controller's color graphics port.

pascal CGrafPtr MCGetControllerPort (MovieController mc);
mc
Specifies the movie controller for the operation. You obtain this identifier from the Component Manager's OpenComponent or OpenDefaultComponent function, or from the NewMovieController function (described on NewMovieController ).

© 1997 Apple Computer, Inc.

Previous | Chapter Top | Chapter Contents | Next